package com.xnewtech.xplatform.swan.gateway.config;

import com.xnewtech.xplatform.swan.gateway.core.filters.AddAuthHeaderFilter;
import com.xnewtech.xplatform.swan.gateway.core.filters.RequestNoFilter;
import com.xnewtech.xplatform.swan.gateway.core.filters.factory.JwtTokenGatewayFilterFactory;
import com.xnewtech.xplatform.swan.gateway.core.filters.factory.PermissionAuthGatewayFilterFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 过滤器的配置
 *
 * @author xnew
 * @date 2017-11-08-下午3:23
 */
@Configuration
public class FilterConfig {

    /**
     * 请求号header过滤器
     *
     * @author xnew
     * @Date 2019/5/12 14:47
     */
    @Bean
    public RequestNoFilter requestNoFilter() {
        return new RequestNoFilter();
    }

    /**
     * 添加auth header过滤器
     *
     * @author xnew
     * @Date 2019/5/12 14:47
     */
    @Bean
    public AddAuthHeaderFilter authHeaderFilter() {
        return new AddAuthHeaderFilter();
    }

    /**
     * token校验过滤器
     *
     * @author xnew
     * @Date 2019/5/12 14:47
     */
    @Bean
    public JwtTokenGatewayFilterFactory jwtTokenGatewayFilterFactory() {
        return new JwtTokenGatewayFilterFactory();
    }

    /**
     * 权限资源校验过滤器
     *
     * @author xnew
     * @Date 2019/5/12 14:47
     */
    @Bean
    public PermissionAuthGatewayFilterFactory permissionAuthGatewayFilterFactory() {
        return new PermissionAuthGatewayFilterFactory();
    }

}
